package xyz.xiaomeiqiu.netty.inbound;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpObjectAggregator;
import io.netty.handler.codec.http.HttpServerCodec;

import java.util.List;

public class HttpInboundInitializer extends ChannelInitializer<SocketChannel> {

    private final List<String> proxyServer;

    public HttpInboundInitializer(List<String> proxyServer){
        this.proxyServer = proxyServer;
    }

    @Override
    protected void initChannel(SocketChannel ch) {
        ChannelPipeline pipeline = ch.pipeline();
        pipeline.addLast(new HttpServerCodec())// http server 编码器
                .addLast(new HttpObjectAggregator(1024*1024)) // 报文聚合器
                .addLast(new HttpInboundHandler(this.proxyServer));
    }
}
